// $codepro.audit.disable
import static org.junit.Assert.*;

import org.junit.Test;
/**
 * JUnit Test to check the Add User method in Admin
 * 
 * @author Team 9
 *
 */
public class AdminAddUserTest {
	/**
	 * The junit test method for addUser (Admin)
	 */
	@Test
	public void testAddUser() {
		Patient p1 = new Patient("Patient", "One", "patient", "one");
		Patient p2 = new Patient("Patient", "Two", "patient", "two");
		Admin a1 = new Admin("Admin", "One", "admin", "one");
		Gui.addToPatientArray(p1);
		Gui.addToPatientArray(p2);
		int before = 0;
		for (int i = 0; i < Gui.getPatientArray().size(); i++) {
			Gui.getPatientArray().get(i).setType(3);
			before++;
		}
		for (int i = 0; i < Gui.getNurseArray().size(); i++) {
			Gui.getNurseArray().get(i).setType(2);
			before++;
		}
		for (int i = 0; i < Gui.getDoctorArray().size(); i++) {
			Gui.getDoctorArray().get(i).setType(1);
			before++;
		}

		// System.out.println(before);
		a1.addUser();

		int after = 0;
		for (int i = 0; i < Gui.getPatientArray().size(); i++) {
			Gui.getPatientArray().get(i).setType(3);
			after++;
		}
		for (int i = 0; i < Gui.getNurseArray().size(); i++) {
			Gui.getNurseArray().get(i).setType(2);
			after++;
		}
		for (int i = 0; i < Gui.getDoctorArray().size(); i++) {
			Gui.getDoctorArray().get(i).setType(1);
			after++;
		}
		// will fail if the wrong user value is put in
		assertEquals(before + 1, after);

	}
}
